package com.itrus.nacos.dubbo.customer.controller;

import com.itrus.nacos.dubbo.api.ProviderApi;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lipeigen
 * Date: 2022/3/22 7:18 PM
 */
@RestController
public class TestController {

    /**
     * cluster:
     * failover：失败自动切换
     * failfast：只调用一次，失败立即报错
     * failsafe：出现异常时，直接忽略
     * failback：后台记录失败请求，定时重发。通常用于消息通知操作 不可靠，重启丢失。
     * forking：并行调用多个服务器，只要一个成功即返回
     */
    @Reference(version = "1.0.0", interfaceClass = ProviderApi.class, cluster = "failfast")
    private ProviderApi providerApi;

    @GetMapping("/hello")
    public String hello(String name) {
        return providerApi.hello(name);
    }

}
